﻿namespace Sidvall.FileSystemManager.Net.Services.V1
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class SearchConfig : global::Sidvall.Data.ServiceDataRowBase, global::Sidvall.FileSystemManager.Data.ISearchConfig
    {
        #region Public Members

        #region CaseSensitive

        private bool _CaseSensitive;
        partial void OnBeforeCaseSensitivePropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterCaseSensitivePropertyChanged();
        public bool CaseSensitive
        { 
            get
            {
                return _CaseSensitive;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _CaseSensitive = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _CaseSensitive);
                    OnBeforeCaseSensitivePropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("CaseSensitive", eventData.Value, true, true);
                        OnAfterCaseSensitivePropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region FileSearchPatterns

        private string _FileSearchPatterns;
        partial void OnBeforeFileSearchPatternsPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterFileSearchPatternsPropertyChanged();
        public string FileSearchPatterns
        { 
            get
            {
                return _FileSearchPatterns;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _FileSearchPatterns = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _FileSearchPatterns);
                    OnBeforeFileSearchPatternsPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("FileSearchPatterns", eventData.Value, true, true);
                        OnAfterFileSearchPatternsPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region FolderPath

        private string _FolderPath;
        partial void OnBeforeFolderPathPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterFolderPathPropertyChanged();
        public string FolderPath
        { 
            get
            {
                return _FolderPath;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _FolderPath = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _FolderPath);
                    OnBeforeFolderPathPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("FolderPath", eventData.Value, true, true);
                        OnAfterFolderPathPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region LoadDetails

        private bool _LoadDetails;
        partial void OnBeforeLoadDetailsPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterLoadDetailsPropertyChanged();
        public bool LoadDetails
        { 
            get
            {
                return _LoadDetails;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _LoadDetails = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _LoadDetails);
                    OnBeforeLoadDetailsPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("LoadDetails", eventData.Value, true, true);
                        OnAfterLoadDetailsPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region SearchConfigId

        private System.Nullable<int> _SearchConfigId;
        partial void OnBeforeSearchConfigIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData);
        partial void OnAfterSearchConfigIdPropertyChanged();
        public System.Nullable<int> SearchConfigId
        { 
            get
            {
                return _SearchConfigId;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _SearchConfigId = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<int>>(value, _SearchConfigId);
                    OnBeforeSearchConfigIdPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("SearchConfigId", eventData.Value, true, true);
                        OnAfterSearchConfigIdPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region SearchFileContent

        private bool _SearchFileContent;
        partial void OnBeforeSearchFileContentPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterSearchFileContentPropertyChanged();
        public bool SearchFileContent
        { 
            get
            {
                return _SearchFileContent;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _SearchFileContent = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _SearchFileContent);
                    OnBeforeSearchFileContentPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("SearchFileContent", eventData.Value, true, true);
                        OnAfterSearchFileContentPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region SearchFileName

        private bool _SearchFileName;
        partial void OnBeforeSearchFileNamePropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterSearchFileNamePropertyChanged();
        public bool SearchFileName
        { 
            get
            {
                return _SearchFileName;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _SearchFileName = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _SearchFileName);
                    OnBeforeSearchFileNamePropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("SearchFileName", eventData.Value, true, true);
                        OnAfterSearchFileNamePropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region SearchFolderName

        private bool _SearchFolderName;
        partial void OnBeforeSearchFolderNamePropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterSearchFolderNamePropertyChanged();
        public bool SearchFolderName
        { 
            get
            {
                return _SearchFolderName;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _SearchFolderName = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _SearchFolderName);
                    OnBeforeSearchFolderNamePropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("SearchFolderName", eventData.Value, true, true);
                        OnAfterSearchFolderNamePropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region SearchPatterns

        private string _SearchPatterns;
        partial void OnBeforeSearchPatternsPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterSearchPatternsPropertyChanged();
        public string SearchPatterns
        { 
            get
            {
                return _SearchPatterns;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _SearchPatterns = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _SearchPatterns);
                    OnBeforeSearchPatternsPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("SearchPatterns", eventData.Value, true, true);
                        OnAfterSearchPatternsPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.SearchConfigManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowStateIsDirty

        protected override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.SearchConfigManager.DataRowStateIsDirty(this);
            }
        }

        #endregion
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade, bool updateState)
        {
            global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.SearchConfigManager.LoadInstanceField(this, fieldName, value, cascade, false, updateState);
        }

        #endregion
        #region Copy

        public SearchConfig Copy()
        {
            return global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.SearchConfigManager.Copy(this);
        }
        public SearchConfig Copy(Sidvall.Data.CopySettings settings)
        {
            return global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.SearchConfigManager.Copy(this, settings);
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.FileSystemManager.Data.ISearchConfig item)
        {
            global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.SearchConfigManager.Import(this, item);
        }
        public void Import(global::Sidvall.FileSystemManager.Data.ISearchConfig item, Sidvall.Data.CopySettings settings)
        {
            global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.SearchConfigManager.Import(this, item, settings);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.SearchConfigManager.ValidateAsync(this).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            return await global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.SearchConfigManager.ValidateAsync(this, settings).ConfigureAwait(false);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.SearchConfigManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.SearchConfigManager.Initialize(this, settings);
        }

        #endregion

        #region ISearchConfig Members

        bool global::Sidvall.FileSystemManager.Data.ISearchConfig.CaseSensitive
        {
            get
            {
                return this._CaseSensitive;
            }
            set
            {
                this._CaseSensitive = value;
            }
        }
        string global::Sidvall.FileSystemManager.Data.ISearchConfig.FileSearchPatterns
        {
            get
            {
                return this._FileSearchPatterns;
            }
            set
            {
                this._FileSearchPatterns = value;
            }
        }
        string global::Sidvall.FileSystemManager.Data.ISearchConfig.FolderPath
        {
            get
            {
                return this._FolderPath;
            }
            set
            {
                this._FolderPath = value;
            }
        }
        bool global::Sidvall.FileSystemManager.Data.ISearchConfig.LoadDetails
        {
            get
            {
                return this._LoadDetails;
            }
            set
            {
                this._LoadDetails = value;
            }
        }
        System.Nullable<int> global::Sidvall.FileSystemManager.Data.ISearchConfig.SearchConfigId
        {
            get
            {
                return this._SearchConfigId;
            }
            set
            {
                this._SearchConfigId = value;
            }
        }
        bool global::Sidvall.FileSystemManager.Data.ISearchConfig.SearchFileContent
        {
            get
            {
                return this._SearchFileContent;
            }
            set
            {
                this._SearchFileContent = value;
            }
        }
        bool global::Sidvall.FileSystemManager.Data.ISearchConfig.SearchFileName
        {
            get
            {
                return this._SearchFileName;
            }
            set
            {
                this._SearchFileName = value;
            }
        }
        bool global::Sidvall.FileSystemManager.Data.ISearchConfig.SearchFolderName
        {
            get
            {
                return this._SearchFolderName;
            }
            set
            {
                this._SearchFolderName = value;
            }
        }
        string global::Sidvall.FileSystemManager.Data.ISearchConfig.SearchPatterns
        {
            get
            {
                return this._SearchPatterns;
            }
            set
            {
                this._SearchPatterns = value;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public SearchConfig()
        {
        }
        public SearchConfig(bool initializeDefaultValues)
            : this(initializeDefaultValues, null, Sidvall.Business.BusinessEvents.None)
        {
        }
        public SearchConfig(bool initializeDefaultValues, Sidvall.Data.DataRowState? dataRowState, Sidvall.Business.BusinessEvents enabledBusinessEvents)
            : base(dataRowState, enabledBusinessEvents)
        {
            if (initializeDefaultValues)
                global::Sidvall.FileSystemManager.SystemContext.Current.EntityFacade.SearchConfigManager.Initialize(this);
        }

        #endregion
    }
}